#!/bin/sh

# build everything in the projects directory
PROJECTS=`echo project/*.mk | xargs -n1 basename | sed 's/\.mk//'`
FAILED=""

case `uname` in
Linux)
	N=`cat /proc/cpuinfo | grep processor | wc -l`
	PARALLEL=-j`expr $N + $N`
	;;
*)
	PARALLEL=-j4
	;;
esac

for p in $PROJECTS; do
	PROJECT=$p nice make $PARALLEL || FAILED="$FAILED $p"
done

if [ "$FAILED" != "" ]; then
	echo
	echo some projects have failed to build:
	echo $FAILED
fi
